const arr=[1,2,3,[4,5],[6,7,8,9]]
function removeArray(arr,a=[]) {
  for (let i = 0; i < arr.length; i++) {
    if (Array.isArray(arr[i])) {
      removeArray(arr[i],a)
    } else {
      a.push(arr[i])
    }
  }
  return a
}

console.log(removeArray(arr))
